Skip to content

Move to ES bridge API #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mashhurs
Copy link
Collaborator

@mashhurs mashhurs commented Jul 10, 2025

Description

This PR highlights the initial changes required to move to the Bridge Stable API. However, this doesn't mean these changes will be enough for the plugin to be a in normal working state. Rather, this changes highlight how does current bridge Spable API state align with plugin requirements. Based on the discussions on these changes, we may need to adjust the plan (sub-tasks).

Next steps

PLEASE IGNORE:

extensions.add(new ConstantKeywordPainlessExtension()); // module: constant-keyword
extensions.add(new ProcessorsWhitelistExtension()); // module: ingest-common
extensions.add(new SpatialPainlessExtension()); // module: spatial
extensions.add(new WildcardPainlessExtension()); // module: wildcard
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these 4-extentions are missing ones.
When running integration tests, I get cannot resolve symbol [Processors] (below log is with a bit more context) error which I believe belong to this painless ProcessorsWhitelistExtension.

logstash-1       | Caused by: java.lang.IllegalArgumentException: cannot resolve symbol [Processors]
logstash-1       |      at org.elasticsearch.painless.PainlessScript$Script.compile(long bytes = Processors.bytes(params['size']); ctx.size_in_bytes = bytes;:24) ~[?:?]
logstash-1       |      at org.elasticsearch.painless.phase.DefaultSemanticAnalysisPhase.visitCall(DefaultSemanticAnalysisPhase.java:3233) 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we will need to find a way to apply #162 on the bridge-side in Elasticsearch.


sourceAndMetadata.put(IngestDocument.Metadata.VERSION.getFieldName(), Objects.requireNonNullElse(sourceVersion, 1L));
// TODO: make IngestDocument.Metadata.VERSION.getFieldName() available
sourceAndMetadata.put("_version", Objects.requireNonNullElse(sourceVersion, 1L));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to wrap IngestDocument.Metadata as well. For now I wanted fully isolate plugin from the IngestDocument.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be in favor of adding a public static final class Constants or similar to the IngestDocumentBridge:

// public class IngestDocumentBridge extends StableBridgeAPI.Proxy<IngestDocument> {
    public static final class Constants {
        private Constants() {}

        public static final String METADATA_VERSION_FIELD_NAME = IngestDocument.Metadata.VERSION.getFieldName();
        // ...
    }
// }

return new GeoIpProcessor.Factory("geoip", this.ipDatabaseProvider)
.create(processorFactories, tag, description, config, projectId);
Map<String, Object> config) throws Exception {
return ProcessorBridge.wrap(new GeoIpProcessor.Factory("geoip", this.ipDatabaseProvider)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will move rg.elasticsearch.ingest.geoip.GeoIpProcessor usage separately with GeoIP task.

import org.elasticsearch.ingest.Processor;
import org.elasticsearch.plugins.IngestPlugin;
import org.elasticsearch.logstashbridge.ingest.ProcessorBridge;
import org.elasticsearch.logstashbridge.plugins.IngestPluginBridge;
import org.elasticsearch.license.XPackLicenseState;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to move all processors (including this source piece) to ES with next iterations.

@mashhurs mashhurs changed the base branch from move-to-es-bridge-api to main July 10, 2025 23:13
Copy link

mergify bot commented Jul 10, 2025

This pull request does not have a backport label. Could you fix it @mashhurs? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

@mashhurs mashhurs added the backport-skip Skip automated backport with mergify label Jul 10, 2025
@mashhurs mashhurs force-pushed the move-to-es-bridge-investigation branch from 0707b1b to bc9af21 Compare July 10, 2025 23:16
@mashhurs mashhurs changed the title [Move to ES bridge API] Investigation DO NOT MERGE: [Move to ES bridge API] Investigation Jul 10, 2025
@mashhurs mashhurs force-pushed the move-to-es-bridge-investigation branch from 18333c6 to 5a96c8c Compare July 17, 2025 20:06
@mashhurs mashhurs changed the title DO NOT MERGE: [Move to ES bridge API] Investigation [DO NOT MERGE]: Move to ES bridge API Jul 18, 2025
@mashhurs mashhurs force-pushed the move-to-es-bridge-investigation branch from 9820699 to 9bdad09 Compare July 22, 2025 19:44
@mashhurs mashhurs changed the title [DO NOT MERGE]: Move to ES bridge API Move to ES bridge API Jul 23, 2025
@@ -1,2 +1,3 @@
LOGSTASH_PATH=../../logstash
ELASTICSEARCH_TREEISH=main
ELASTICSEARCH_REPO=mashhurs/elasticsearch
ELASTICSEARCH_TREEISH=move-to-bridge-stable-api-investigation
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary PoC, will be rolled back to origin once upstream PR is merged.

@mashhurs mashhurs force-pushed the move-to-es-bridge-investigation branch from 09c332c to 9b0b557 Compare August 7, 2025 23:58
@mashhurs mashhurs force-pushed the move-to-es-bridge-investigation branch from fa3468c to 53ded41 Compare August 8, 2025 18:40
@@ -307,10 +307,6 @@ task shadeElasticsearchIngestGeoIpModule(type: com.github.jengelman.gradle.plugi

mergeServiceFiles()

String shadeNamespace = "org.elasticsearch.ingest.geoip.shaded"
relocate('com.fasterxml.jackson', "${shadeNamespace}.com.fasterxml.jackson")
relocate('com.maxmind', "${shadeNamespace}.com.maxmind")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We get "No X class found" exceptions if we relocate them and I am not seeing org.elasticsearch.ingest.geoip.shaded.com.fasterxml.jackson.* usages.

@@ -1,2 +1,3 @@
LOGSTASH_PATH=../../logstash
ELASTICSEARCH_TREEISH=main
ELASTICSEARCH_REPO=mashhurs/elasticsearch
ELASTICSEARCH_TREEISH=logstash-bridge-geoip-interfaces
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: this will be removed once upstream PR is merged.


import org.elasticsearch.ingest.geoip.IpDatabase;

public interface ValidatableIpDatabase extends IpDatabase {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No direct usage.


import java.util.Map;

public class RedactPlugin extends Plugin implements IngestPlugin {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to the upstream bridge.

import org.elasticsearch.cluster.project.ProjectResolver;
import org.elasticsearch.core.CheckedRunnable;

public class PluginProjectResolver implements ProjectResolver {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to the bridge, ProjectIdResolverBridge class.

@mashhurs mashhurs marked this pull request as ready for review August 11, 2025 16:51
@elasticmachine
Copy link
Collaborator

elasticmachine commented Aug 11, 2025

💔 Build Failed

Failed CI Steps

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip automated backport with mergify
Projects
None yet
3 participants